import axios from 'axios'
import config from '@/config/index.js'
const baseURL = process.env.NODE_ENV === 'development' ? config.baseUrl.dev : config.baseUrl.pro;

class HttpRequest{
	constructor(baseURL){
		this.baseURL = baseURL;
	}
	getInsideConfig(){
		const config = {
			baseURL:this.baseURL,
			timeout:5000,
			// headers:{
			// 	'Content-Type': 'multipart/form-data'
			// }
		}
		return config;
	}
	interceptors(instance,options){
		instance.interceptors.request.use(options=>{
			return options
		}),
		instance.interceptors.response.use(res=>{
			return res.data
		},err=>{return err})
	}
	request(options){
		const instance = axios.create(this.getInsideConfig());
		this.interceptors(instance,options);
		return instance(options)
	}
}
export default new HttpRequest(baseURL)